package com.fary.vo;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.experimental.var;

import java.math.BigDecimal;
import java.util.Date;

public class TestJackson {

    public static void main(String[] args) throws JsonProcessingException {
        User user = new User();
        user.setName("zhangsan");
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializerFactory(mapper.getSerializerFactory().withSerializerModifier(new MyBeanSerializerModifier()));
        String value = mapper.writeValueAsString(user);
        System.out.println(value);

        double decimal = NumberUtil.div("2", "1").doubleValue();
        System.out.println(decimal);

        JSONObject jsonObject = JSONUtil.parseObj("{\"id\":{\"name\":\"zhangsan\"},\"name\":\"zhangsan\",\"age\":null,\"list\":[]}");
        User user1 = JSON.parseObject("{\"id\":{\"name\":\"zhangsan\"},\"name\":\"zhangsan\",\"age\":null,\"list\":[]}", User.class);
        System.out.println(user1);


        String sub = StrUtil.sub("12", 0, 5);
        System.out.println(sub);

    }
}
